------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  E:\REStat_MS14767_Vol96(2)\Data preparation Compustat segment\6_raw_rjv_panel_america.log
  log type:  text
 opened on:  18 Dec 2014, 18:06:19

. *-----------------------------------------------------------------
. 
. ****************************************
. * This short file  drops non-american firms
. * from the RJV data set as well as observations from 1985
. * and entries without ticker.
. ****************************************
. 
. 
. *************
. * generate inside/outside dummy
. *************
. 
. use "raw_rjv_panel.dta", clear

. gen ins=0

. replace ins=1 if year>= eyear
(92265 real changes made)

. replace ins=0 if year> xyear
(12360 real changes made)

. 
. *************
. *we drop all infos from 1985 (we do not have COMPUSTAT data for that year)
. *************
. 
. count if year==1985
14016

. * 14016
. drop if year==1985
(14016 observations deleted)

. 
. 
. *************
. *we drop all firms that have no ticker (we cannot use them in the market share analysis)
. *************
. 
. count if ticker==""
112560

. * 112560
. 
. drop if ticker==""
(112560 observations deleted)

. 
. 
. merge m:1 ticker year using "ticker_year.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                       141,677
        from master                    28,555  (_merge==1)
        from using                    113,122  (_merge==2)

    matched                            55,109  (_merge==3)
    -----------------------------------------

. tab _merge

                 _merge |      Freq.     Percent        Cum.
------------------------+-----------------------------------
        master only (1) |     28,555       14.51       14.51
         using only (2) |    113,122       57.48       72.00
            matched (3) |     55,109       28.00      100.00
------------------------+-----------------------------------
                  Total |    196,786      100.00

. drop if _merge==2
(113122 observations deleted)

. drop _merge

. 
. 
. 
. *-*-*-*-*-*-* NOTE - DATA CORRECTION!!! *-*-*-*-*-*-*-*-*-*
. 
. ******* 
. * here we have to correct for the fact that for each entityname (connected to the TICKER)
. * there might be several entrynames.
. * we choose to say that the "mother" firm is in the RJV if at least one of the entitynames is in
. * we then keep only one observation per entityname, RJV, year.
. *************
. 
. egen ins2=max(ins), by(comnum rjvnum year)

. drop ins

. rename ins2 ins

. sort year comnum rjvnum

. count if rjvnum==rjvnum[_n-1] & year==year[_n-1] & comnum==comnum[_n-1]
10654

. * 8652
. drop if rjvnum==rjvnum[_n-1] & year==year[_n-1] & comnum==comnum[_n-1]
(10654 observations deleted)

. 
. *-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*
. 
. save raw_rjv_panel_segment.dta, replace
file raw_rjv_panel_segment.dta saved

. 
. log close
      name:  <unnamed>
       log:  E:\REStat_MS14767_Vol96(2)\Data preparation Compustat segment\6_raw_rjv_panel_america.log
  log type:  text
 closed on:  18 Dec 2014, 18:06:23
------------------------------------------------------------------------------------------------------------------------------------------
